<!DOCTYPE html>
 <html>
 <head>
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
 <% include("/view/console/common/css.html"){}	%>

 <title></title>
 </head>
 <body>
 <div class="zq-form">
 <form name="boBanner_form"  id="boBanner_form" class="form-horizontal" style="margin-bottom: 70px;">
   <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">Banner题目</label>
 <div class="col-sm-6 col-xs-6">
 <input  type="text"  name="title" id="title" class="form-control" check-type="required" maxlength='512' value='${boBanner.title!}' >
 </div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">描述</label>
 <div class="col-sm-6 col-xs-6">
   <textarea name="des" id="des" placeholder="请输入内容" check-type="" maxlength='512' class="layui-textarea">${boBanner.des!}</textarea></div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">目标地址</label>
 <div class="col-sm-6 col-xs-6">
 <input  type="text"  name="target" id="target" class="form-control" check-type="" maxlength='1024' value='${boBanner.target!}' >
 </div>
  </div>
 <div class="form-group">
 <label class="control-label col-sm-2 col-xs-2">跳转类型</label>
 <div class="col-sm-6 col-xs-6">
 	<select class="form-control" id="targetType"
 		name="targetType" check-type=" number" >
 	<option selected='selected' value="1">网页</option>
 </select>
 </div>
 </div>
 <div class="form-group">
 <label class="control-label col-sm-2 col-xs-2">Banner类型</label>
 <div class="col-sm-6 col-xs-6">
 	<select class="form-control" id="type"
 		name="type" check-type="" maxlength='32'>
 	<option selected='selected' value="1">官网首页轮播</option>
 </select>
 </div>
 </div>
 <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">排序</label>
 <div class="col-sm-6 col-xs-6">
 <input  type="text"  name="sort" id="sort" class="form-control" check-type=" number"  value='${boBanner.sort!}' >
 </div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">状态</label>
 <div class="col-sm-6 col-xs-6">
 <div class="radio">
 <label><input checked='checked' auto_name='boBanner_status' type="radio"  name="status" value="1"/>可用</label>
 <label><input  auto_name='boBanner_status' type="radio"  name="status" value="0"/>不可用</label>
  
 </div>
 </div>
  </div>
  <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">banner图片</label>
 <div class="col-sm-3 col-xs-3">
   <span class="btn btn-success fileinput-button">
        <i class="glyphicon glyphicon-plus"></i>
        <span>添加</span>
  <input type="file" id="bannerImg_file" class="form-control" value='${boBanner.bannerImg!}' >
  <input type="hidden" id="bannerImg"  name="bannerImg"class="form-control" value='${boBanner.bannerImg!}' >
    </span>
  <div id="bannerImg_progress" class="progress">
   <div class="progress-bar progress-bar-success"></div>
  </div>
  </div>
   	<div class="col-sm-4 col-xs-4">
   	<img id="bannerImg_file_show" src="${boBanner.bannerImg!}" style="width:100px;word-wrap: break-word;" alt="图片" class="img-rounded">
 </div>
 </div>
   <input type='hidden' name='id' id='id' value='${boBanner.id!}'><input type='hidden' name='common_token' id='common_token' value='${common_token!}'>
 </form>
  <nav class="navbar navbar-default navbar-fixed-bottom" style="text-align: right">
    <a href="#" class="btn btn-success" style="margin:10px" id = "saveForm">保存 </a>
  </nav>
 </div>
 <% include("/view/console/common/js.html"){} 	%>
 <script>


    layui.use(['layer','laydate'], function(){
    var laydate = layui.laydate;
    var layer = layui.layer;
    /*开启表单验证*/
    $("#boBanner_form").validation();
        
	$("#targetType").val("${boBanner.targetType!}");
 	if('${boBanner.targetType!}'==''){
 	    $("#targetType").val('1');
 	}
 
	$("#type").val("${boBanner.type!}");
 	if('${boBanner.type!}'==''){
 	    $("#type").val('1');
 	}
    
   $('input[auto_name="boBanner_status"]').each(function(){
    
   if('${boBanner.status!}'==this.value){ 
             $(this).attr('checked','checked');
            }
           });
 consoleUploadAliImg('bannerImg','');



    $("#saveForm").click(function(){
        saveZqForm();

    })
    function saveZqForm(){
        if ($("#boBanner_form").valid() == false) {
        return false;
        }
        var formObject=new Object();
        formObject.title=$('#title').val()==''?null:$('#title').val(); 
 formObject.des=$('#des').val()==''?null:$('#des').val(); 
 formObject.bannerImg=$('#bannerImg').val()==''?null:$('#bannerImg').val(); 
 formObject.target=$('#target').val()==''?null:$('#target').val(); 
 formObject.targetType=$('#targetType').val()==''?null:$('#targetType').val(); 
 formObject.type=$('#type').val()==''?null:$('#type').val(); 
 formObject.sort=$('#sort').val()==''?null:$('#sort').val(); 
 formObject.status=($('input[name="status"]:checked').val()==''?null:$('input[name="status"]:checked').val()); 
 formObject.id=$('#id').val()==''?null:$('#id').val(); 
 
        var formObjectJson = JSON.stringify(formObject);
        $.post("/console/bo_banner/save",
        {
        formObjectJson :formObjectJson,
        common_token :$("#common_token").val()
        }, function(data) {
        layer.alert(data.message, {skin: 'layui-layer-molv',closeBtn: 0 }, function(){
        parent.$("#boBanner").bootstrapTable("refresh");
        parent.layer.closeAll();
        });

        });
        }
    });

 </script>
 </body>
